<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en">
	<h:head />
	<body>
		<ui:composition template="/rootWeb.xhtml">
	    <ui:define name="header">
	        <title>机台管理</title>
	        <script type="text/javascript">
				//页面载入时注册
	        	jQuery(document).ready(function(){
	        		//鼠标移入
					jQuery("#machineTable_data tr").live("mouseover", function() {
					  	jQuery(this).css("background-color","#CCCCCC");
					});
					//鼠标移出
					jQuery("#machineTable_data tr").live("mouseout", function() {
					  	jQuery(this).css("background-color","white");
					});
				});
			</script>
			<style type="text/css">
				
			</style>
		</ui:define>
	    <ui:define name="body">
	    	<h:form id="form" prependId="false">
				<p:dataTable id="machineTable" value="#{machineAction.machineList}" var="machine" rowKey="#{machine}" emptyMessage="没有记录！"
	    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
               			<f:facet name="header">机台列表</f:facet>
               			<p:column headerText="机台编码">#{machine.machineCode}</p:column>
               			<p:column headerText="机台号">#{machine.machineNumber}</p:column>
               			<p:column headerText="机台状态">
               				<h:selectOneMenu value="#{machine.machineState}" disabled="true" style="width:120px">  
				                <f:selectItems value="#{machineAction.machineStateItems}"/>
				            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="描述">#{machine.machineRemark}</p:column>
               			<p:column headerText="操作">
			    			<p:commandLink value="修改" action="#{machineAction.setUpdateMachine(machine)}" oncomplete="updateMachineDlg.show()" update=":form:updateMachineDlgID" style="margin-right:5px;color:RED"/>
			    			<p:commandLink value="删除" action="#{machineAction.setUpdateMachine(machine)}" oncomplete="deleteMachineDlg.show()" update=":form:updateMachineDlgID" style="color:RED"/>
			    		</p:column>
			    		<f:facet name="footer">
							<p:commandButton value="新增" action="#{machineAction.addMachine}" update=":form:addMachineDlgID" oncomplete="addMachineDlg.show();"/>
					</f:facet>
               	</p:dataTable>
               	<!-- 删除 -->
				<p:confirmDialog id="deleteMachineDlgID" message="删除机台将删除机台所对应的系统帐户，确认删除机台吗?"
					header="删除机台" severity="alert" widgetVar="deleteMachineDlg">
					<p:commandButton value="确定" update=":form:machineTable" action="#{machineAction.doDeleteMachine}"
						oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);deleteMachineDlg.hide();}"  />
					<p:commandButton value="取消" onclick="deleteMachineDlg.hide()" type="button" />
				</p:confirmDialog>
               	<!--  新增 -->
               	<p:dialog id="addMachineDlgID" header="新增机台" widgetVar="addMachineDlg" modal="true" resizable="false" >
					<p:outputPanel style="width: 100%" >
						<h:panelGrid columns="2">
							<h:outputLabel for="addMachineNumber" value="机台号："/>
							<p:inputText id="addMachineNumber" value="#{machineAction.addMachine.machineNumber}" />
							<h:outputLabel for="addMachineCode" value="机台编码："/>
							<h:panelGrid columns="2">
								<p:inputText id="addMachineCode" value="#{machineAction.addMachine.machineCode}" />
								<H5 style="color:RED;padding: 0px;margin: 0px">机台为登录系统的帐户名，不可修改！</H5>
							</h:panelGrid>
							<h:outputLabel for="addMachineState" value="机台状态："/>
							<h:selectOneMenu id="addMachineState" value="#{machineAction.addMachine.machineState}" >  
				                <f:selectItems value="#{machineAction.machineStateItems}"/>
				            </h:selectOneMenu>
				            <h:outputLabel for="addMachineRemark" value="描述："/>
							<p:inputTextarea id="addMachineRemark" value="#{machineAction.addMachine.machineRemark}" rows="1" autoResize="false" maxlength="300" style="width:430px"/>
						</h:panelGrid>
					</p:outputPanel>
					<f:facet name="footer">
						<p:commandButton value="保存" update=":form:machineTable" action="#{machineAction.saveMachine}"
							oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);addMachineDlg.hide();}"  />
					</f:facet>
				</p:dialog>
				
				<!--  修改 -->
               	<p:dialog id="updateMachineDlgID" header="新增机台" widgetVar="updateMachineDlg" modal="true" resizable="false" >
					<p:outputPanel style="width: 100%" >
						<h:panelGrid columns="2">
							<h:outputLabel for="updateMachineNumber" value="机台号："/>
							<p:inputText id="updateMachineNumber" value="#{machineAction.updateMachine.machineNumber}" />
							<h:outputLabel for="updateMachineState" value="返厂日期："/>
							<h:selectOneMenu id="updateMachineState" value="#{machineAction.updateMachine.machineState}" >  
				                <f:selectItems value="#{machineAction.machineStateItems}"/>
				            </h:selectOneMenu>
				            <h:outputLabel for="updateMachineRemark" value="描述："/>
							<p:inputTextarea id="updateMachineRemark" value="#{machineAction.updateMachine.machineRemark}" rows="1" autoResize="false" maxlength="300" style="width:430px"/>
						</h:panelGrid>
					</p:outputPanel>
					<f:facet name="footer">
						<p:commandButton value="更新" update=":form:machineTable" action="#{machineAction.updateMachine}"
							oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);updateMachineDlg.hide();}"  />
					</f:facet>
				</p:dialog>
			</h:form>
	    </ui:define>
		</ui:composition>
	</body>
</html>
